//
//  SYDismissAnimation.swift
//  SingWeibo
//
//  Created by shiying on 16/1/1.
//  Copyright © 2016年 shiying. All rights reserved.
//

import UIKit

class SYDismissAnimation: NSObject, UIViewControllerAnimatedTransitioning {
    
    func transitionDuration(transitionContext: UIViewControllerContextTransitioning?) -> NSTimeInterval {
        return 0.25
    }
    
    func animateTransition(transitionContext: UIViewControllerContextTransitioning) {
        // 获取到modal出来的控制器
        let fromView = transitionContext.viewForKey(UITransitionContextFromViewKey)
        
        UIView.animateWithDuration(transitionDuration(transitionContext), animations: { () -> Void in
            fromView?.transform = CGAffineTransformMakeScale(1, 0.001)
            }) { (_) -> Void in
                transitionContext.completeTransition(true)
        }
    }
    
    

}
